<template>
	<view class="repair">
		<view style="width: 100%;background-color: #FFFFFF;">
			<view class="cardCon" style="background-color: #FFFFFF;">
				<view class="list-li">
					<view class="list-name">
						<text style="color: #000000;font-weight: 700;font-size: 18px;">{{name}}服务记录</text>
					</view>
				</view>

				<view v-if="this.repairList.length == 0">
					<view style="width: 232px;height: 242px;margin: 110px auto;">
						<image style="width: 100%;height: 100%;"
							src="https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/zanwushuju.png" mode=""></image>
					</view>
					<view style="width: 62%;margin: -66px auto;text-align: center;color: #999;">暂无数据</view>
				</view>
				<view>
					<view v-for="(item,index) in repairList">

						<uni-card :is-shadow="false">
							<view class="uni-body" style="font-size: 15px;">
								<view>
									<span style="color: #666666;">服务名称：</span>
									<span style="color: #000000;">{{item.name}}</span>
								</view>
								<view style="margin-top: 10px;">
									<span style="color: #666666;">服务人员(物业)：</span>
									<span style="color: #000000;">{{item.user_name}}</span>
								</view>
								<view style="margin-top: 10px;">
									<span style="color: #666666;">服务类型：</span>
									<span style="color: #000000;">{{item.types}}</span>
								</view>
								<view style="margin-top: 10px;">
									<span style="color: #666666;">服务内容：</span>
									<span style="color: #000000;">{{item.content}}</span>
								</view>
								<view style="width: 120px;height: 120px;margin-top: 10px;">
									<image @click="imageBig(item.service_image)" style="width: 100%;height: 100%;"
										:src="item.service_image" mode=""></image>
								</view>
							</view>
						</uni-card>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				typeName: '',
				type: 1,
				pageIndex: 1,
				loading: false,
				nextPage: false,
				listData: [],
				repairList: [],
				name: null
			};
		},
		onLoad(options) {

		},
		onShow() {
			this.checkLogin();
		},
		onPullDownRefresh() {
			this.checkLogin();
		},
		methods: {
			// 验证是否登录或实名认证
			checkLogin() {
				let _this = this
				if (uni.getStorageSync('phone')) {
					if (uni.getStorageSync('loginFlag')) {
						if (!uni.getStorageSync('hourseList')) {
							this.$openInvite()
						} else {
							_this.showFlag = true
							_this.homelist = uni.getStorageSync('hourseList')[uni.getStorageSync('hourseNum') || 0]
							_this.name = _this.homelist.proName;
							_this.address = _this.homelist.buildDistrictCode + '-' + _this.homelist.buildTowerCode + '-' +
								_this.homelist.roomUnitNumber + '-' + _this.homelist.roomCode
							this.homelist = uni.getStorageSync('hourseList')[uni.getStorageSync('hourseNum') || 0],
								this.name = this.homelist.proName;
							_this.serviceRecord()
						}
					} else {
						uni.showModal({
							title: '请先实名认证',
							showCancel: false,
							confirmText: '确认',
							confirmColor: '#F9A832',
							success: function(res) {
								if (res.confirm) {
									_this.$Router.push({
										path: '/homePage1/realName/realName'
									})
								}
							}
						});
					}
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
						confirmText: '确认',
						confirmColor: '#F9A832',
						success: function(res) {
							if (res.confirm) {
								console.log('a')
								_this.$Router.pushTab({
									path: '/pages/user/user'
								})
							}
						}
					});
				}
				uni.stopPullDownRefresh()

			},
			serviceRecord() {
				if (this.pageIndex < 2) {
					uni.showLoading({
						title: '加载中'
					});
				}
				this.loading = false;
				this.$request.api.getserviceRecord({
					room_id: this.homelist.roomId,
				}).then(res => {
					if (this.pageIndex == 1) {
						this.repairList = res.data.data.datalist || [];
					} else {
						this.repairList = [...this.repairList, ...res.data.data.datalist];
					}
					console.log(this.repairList)
					this.nextPage = res.data.data.isEndPage
					// this.loading = true;
					uni.hideLoading();
				})
			},
			//图片预览

			imageBig(url) {
				uni.previewImage({
					urls: [url], //需要预览的图片http链接列表，多张的时候，url直接写在后面就行了
				})
			},



		},
		onReady() {}
	};
</script>

<style>
	.repair {
		width: 100%;


	}

	.cardCon {
		width: 90%;
		margin: 20px auto;
		padding-bottom: 48px;
	}

	.list-li {}

	.list_text_name {
		padding-top: 10px;
	}

	.list-img {
		padding-top: 10px;
	}
</style>
